Fix infinite loop and pointer update bug in decompress_bmi2#231
Fix infinite loop and pointer update bug in decompress_bmi2#231
Conversation
This commit fixes a critical bug in `decompress_bmi2` (x86.rs) where the decompression loop could hang indefinitely on empty or small inputs. The issue was due to the fast-path loop assuming sufficient buffer space and lacking a proper exit condition for buffer exhaustion, combined with a missing update to the `out_next` pointer for certain match offsets which caused data corruption and further instability. The fix involves: 1. Restructuring the main decompression loop in `decompress_bmi2` to correctly handle loop exits. 2. Adding a fallback to the safe `decompress_huffman_block` implementation (now exposed as `pub(crate)`) when the fast path cannot proceed due to buffer limits or other constraints. 3. Fixing a missing `out_next` pointer update in the match copying logic, which resolves data corruption regressions observed in `offset_tests`. 4. Correctly propagating state between the fast path and the fallback. Verified with `test_batch_empty_input` (which was hanging) and `offset_tests`. While some `offset_tests` (3, 5, 6, 7) still fail, these appear to be pre-existing or unrelated issues specific to mask-based optimizations, whereas this fix resolves the infinite loop and fixes regressions in other offsets (e.g., 16+). Co-authored-by: 404Setup <[email protected]>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Fixes an infinite loop in
decompress_bmi2caused by insufficient buffer handling and corrects a pointer update bug that led to data corruption.PR created automatically by Jules for task 6582532249254586770 started by @404Setup